package com.fuluwa.domain.order.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.ForeignKey;

import com.fuluwa.domain.shared.AbstractIdDomainObject;

@Entity
public class PaymentInfo extends AbstractIdDomainObject implements Cloneable {

	private static final long serialVersionUID = -4466554093743239504L;

	@ManyToOne
	@JoinColumn(name = "t_order_id")
	@ForeignKey(name = "null")
	private Order order;

	private Double amount; // 支付金额
	@Enumerated(EnumType.STRING)
	private PayType payType;

	private PaymentInfo() {
	}

	public PaymentInfo(Order order, Double amount, PayType payType) {
		this.order = order;
		this.amount = amount;
		this.payType = payType;
	}

	public PaymentInfo(PayType payType) {
		this.payType = payType;
	}

	public PaymentInfo copyPaymentInfo() {
		return new PaymentInfo(order, amount, payType);
	}

	public Order getOrder() {
		return order;
	}

	public Double getAmount() {
		return amount;
	}

	public PayType getPayType() {
		return payType;
	}

	public void updateOrder(Order order) {
		this.order = order;
	}

	public PaymentInfo update(Order order, Double amount) {
		this.order = order;
		this.amount = amount;
		return this;
	}
}
